from django.conf.urls import url

from meiduo_admin.views import users, statistical, skus, spus, permission

urlpatterns = [

     # 进行url配置

     # 管理员登录
     url(r'^authorizations/$',users.AdminAutorizeView.as_view()),

     # 数据统计
     url(r'^statistical/day_active/',statistical.UserDayActiveView.as_view()),
     url(r'^statistical/day_orders/$', statistical.UserDayOrdersView.as_view()),
     url(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
     # 用户管理
     url(r'^users/$', users.UserInfoView.as_view()),
     # 图片管理
     url(r'^skus/simple/$', skus.SKUSimpleView.as_view()),
     # SKU管理
     url(r'^goods/simple/$', spus.SPUSimpleView.as_view()),
     url(r'^goods/(?P<pk>\d+)/specs/$', spus.SPUSpecView.as_view()),
     url(r'^permission/content_types/$', permission.PermissionViewSet.as_view({
        'get': 'content_types'
    })),
     url(r'^permission/simple/$', permission.GroupViewSet.as_view({
        'get': 'simple'
    })),
    # 管理员管理
    url(r'^permission/groups/simple/$', permission.AdminViewSet.as_view({
        'get': 'simple'
    }))
]

# from rest_framework.routers import DefaultRouter
from rest_framework.routers import SimpleRouter
# 1.创建router对象
# router = DefaultRouter()
router = SimpleRouter()
# 2.注册视图集
router.register('skus/images',skus.SKUImageViewSet,basename='images')
# 3.添加url配置
urlpatterns += router.urls

# SKU管理
router = SimpleRouter()
router.register('skus', skus.SKUViewSet, basename='skus')
urlpatterns += router.urls

# 权限管理
router = SimpleRouter()
router.register('permission/perms', permission.PermissionViewSet, basename='perms')
urlpatterns += router.urls

# 用户组管理
router = SimpleRouter()
router.register('permission/groups', permission.GroupViewSet, basename='groups')
urlpatterns += router.urls

# 用户组管理
router = SimpleRouter()
router.register('permission/admins', permission.AdminViewSet, basename='admins')
urlpatterns += router.urls
# for url in router.urls:
#     print(url)